package bill

import (
	"net/http"

	"github.com/EDDYCJY/go-gin-example/pkg/app"
	"github.com/EDDYCJY/go-gin-example/pkg/e"
	"github.com/EDDYCJY/go-gin-example/service/bill_service"
	"github.com/gin-gonic/gin"
)

type AddBillVerify struct {
	BillList string `alias:"商品 ID" form:"bill_list"  json:"bill_list" valid:"Required;"`
}

func AddBill(c *gin.Context) {
	var (
		appG = app.Gin{C: c}
		form AddBillVerify
	)
	_, errCode := app.BindAndValidMsg(c, &form)
	if errCode != nil {
		appG.ResponseMsg(errCode, nil)
		return
	}

	var data interface{}
	Service := bill_service.AddBill{
		BillList: form.BillList,
	}
	data, err := Service.AddBill()
	if err != nil {
		appG.ResponseMsg(err, nil)
		return
	}
	//异步日志
	appG.Response(http.StatusOK, e.SUCCESS, data)

}
